// app.js
import Toast from '@vant/weapp/toast/toast';
import verifyToken from "./utils/verifyToken"
import {getViewHeight} from "./utils/utils"
import {connetSocket} from "./utils/socketTask"

App({
  async onLaunch() {
    connetSocket()
    // 校验token有效性
    try {
      let ret = await verifyToken()
      // console.log(ret)
      if (ret.code !== 200) {
        // console.log(ret.message);
        wx.reLaunch({
          url: '/pages/login/index',
        })
      }
    } catch (error) {
      console.log("app",error);
    }

    let viewHeight = await getViewHeight()
    this.globalData.viewHeight = viewHeight
  },
  globalData: {
    userInfo: null,
    target:"http://127.0.0.1:3000",
    Toast,
    viewHeight:1200,
  }
})
